package cn.mysdp.biz.facade;


import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import cn.mysdp.biz.dto.request.*;
import cn.mysdp.biz.dto.response.*;
import cn.mysdp.biz.domain.*;
import cn.mysdp.biz.facade.*;
import cn.mysdp.biz.facade.*;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

/**
 * @ClassName: SdpProjectFacadeImpl
 * @Description:
 * @Author: SDP
 * @Date: 2021-10-30
 * @Version: 1.0
 * Table: sdp_project
 * Comment:
 * 
 */
@Service
public class SdpProjectFacadeImpl extends SdpProjectFacadeCustomImpl implements SdpProjectFacade {

    static {
        beanClassNameMap.put("sdp_project", "sdpProjectFacadeImpl");
        listMethodNameMap.put("sdp_project", "listSdpProject");
        listMethodParameterClassNameMap.put("sdp_project", "SdpProjectQueryRequest");
        updateMethodNameMap.put("sdp_project", "updateSdpProject");
        updateMethodParameterClassNameMap.put("sdp_project", "SdpProjectUpdateRequest");
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer addSdpProject(SdpProjectAddRequest request) throws Exception {
        super.fixRequest("sdp_project", "add", request);
        return super.addSdpProject(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer updateSdpProject(SdpProjectUpdateRequest request) throws Exception {
        SdpProject record = null;
        record = sdpProjectMapper.selectByPrimaryKey(request.getId());
        super.fixRequest("sdp_project", "update", request, record);
        return super.updateSdpProject(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer deleteSdpProject(SdpProjectDeleteRequest request) throws Exception {
        if (needCheckDeleteList(request)) {
            List<SdpProject> list = null;
            SdpProjectExample example = new SdpProjectExample();
            example.createCriteria().andIdIn(request.getIdList());
            list = sdpProjectMapper.selectByExample(example);
            fixRequest("sdp_project", "delete", request, list);
        } else {
            fixRequest("sdp_project", "delete", request);
        }
        return super.deleteSdpProject(request);
    }

    @Override
    public SdpProjectQueryResponse querySdpProject(SdpProjectQueryRequest request) throws Exception {
        super.checkNonNull(request.getId(), "id");
        SdpProjectQueryResponse result = super.querySdpProject(request);
        checkResult("sdp_project", "query", request, result);
        return result;
    }

    @Override
    public List<SdpProjectQueryResponse> listSdpProject(SdpProjectQueryRequest request) throws Exception {
        List<SdpProjectQueryResponse> list = super.listSdpProject(request);
        checkResult("sdp_project", "list", request, list);
        return list;
    }

    @Override
    public Integer countSdpProject(SdpProjectQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("sdp_project", "count", request);
        return super.countSdpProject(request);
    }

    @Override
    public BaseStatResponse statSdpProject(SdpProjectQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("sdp_project", "stat", request);
        return super.statSdpProject(request);
    }

    @Override
    public SdpProjectForExecuteResponse execute(SdpProjectForExecuteRequest request) throws Exception {
        super.fixRequest("sdp_project", "execute", request);
        SdpProjectForExecuteResponse result = super.execute(request);
        checkResult("sdp_project", "execute", request, result);
        return result;
    }

    @Override
    public SdpProjectForShellResponse shell(SdpProjectForShellRequest request) throws Exception {
        super.fixRequest("sdp_project", "shell", request);
        SdpProjectForShellResponse result = super.shell(request);
        checkResult("sdp_project", "shell", request, result);
        return result;
    }

    @Override
    public Integer clone(BaseNameIdRequest request) throws Exception {
        super.fixRequest("sdp_project", "clone", request);
        Integer result = super.clone(request);
        checkResult("sdp_project", "clone", request, result);
        return result;
    }

}
